package 
{
		
	import flash.display.Sprite;
	import flash.display.StageAlign;
	import flash.display.StageScaleMode;
	import flash.events.Event;
	import flash.geom.Rectangle;
	
	import starling.core.Starling;	
	import utils.SWFProfiler;
	
	[SWF(width="320", height="480", frameRate="60", backgroundColor="#222222")]
	public class MyStarling extends Sprite
	{
		private var mStarling:Starling;
		
		public function MyStarling()
		{
			stage.scaleMode = StageScaleMode.NO_SCALE;
			stage.align = StageAlign.TOP_LEFT;
			
			Starling.multitouchEnabled = true; // useful on mobile devices
			Starling.handleLostContext = true; // deactivate on mobile devices (to save memory)
			
			SWFProfiler.init(stage,this);

			
			mStarling = new Starling(Game, stage);
			mStarling.simulateMultitouch = true;
			mStarling.enableErrorChecking = true;
			mStarling.start();
			
			// this event is dispatched when stage3D is set up
			mStarling.stage3D.addEventListener(Event.CONTEXT3D_CREATE, onContextCreated);
		}
		
		private function onContextCreated(event:Event):void
		{
			// set framerate to 30 in software mode
			var isHW:Boolean = Starling.context.driverInfo.toLowerCase().indexOf("software") == - 1
			if(isHW)
			{
				Starling.current.nativeStage.frameRate = 30;							
			}
			
		}
	}
}